<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://d3js.org/d3.v5.min.js"></script>
</head>
<body>
    <p></p>
    <p></p>
</body>
<script>
let dataset = [
    {id: 3, name: 'nitx'},
    {id: 9, name: 'nz'},
    {id: 6, name: 'hx'}
];

let p = d3.select( "body" ).selectAll( "p" );

let update = p.data( dataset ),
    enter = update.enter(),
    exit = update.exit();

update.text( function( d, i ){
    return d.id + " " + d.age + ' ' + d.name;
} )

enter.append( "p" )
     .each( function( d, i ){
        d.age = i+20;
        return d;
     } )
     .text( function( d, i ){
        return d.id + " " + d.age + ' ' + d.name;
     } )

// exit.remove();
</script>
